package com.cx.service.impl;

import com.cx.mapper.ChassisMapper;
import com.cx.pojo.Chassis;
import com.cx.service.ChassisService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChassisServiceImpl implements ChassisService {

    @Autowired
    ChassisMapper chassisMapper;

    @Override
    public int insert(Chassis chassis) {
        return chassisMapper.insert(chassis);
    }

    @Override
    public int updateByPrimaryKey(Chassis chassis) {
        return chassisMapper.updateByPrimaryKey(chassis);
    }

    @Override
    public int deleteByPrimaryKey(Integer eId) {
        return chassisMapper.deleteByPrimaryKey(eId);
    }

    @Override
    public Chassis selectByPrimaryKey(Integer eId) {
        return chassisMapper.selectByPrimaryKey(eId);
    }

    //分页
    public PageInfo<Chassis> selectAllChassis(Chassis chassis) {
        PageHelper.startPage(chassis.getPageNum(), chassis.getPageSize());
        List<Chassis> chassisList = chassisMapper.selectAllChassis(chassis);
        return new PageInfo<>(chassisList);
    }
}
